package com.landtool.database.service.impl;

import com.landtool.database.entity.TgMidCountry;
import com.landtool.database.mapper.TgMidCountryMapper;
import com.landtool.database.service.TgMidCountryService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (TgMidCountry)表服务实现类
 *
 * @author lizhao
 * @since 2019-05-13 11:11:13
 */
@Service("tgMidCountryService")
public class TgMidCountryServiceImpl implements TgMidCountryService {
    @Resource
    private TgMidCountryMapper tgMidCountryMapper;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public TgMidCountry queryById(String id) {
        return this.tgMidCountryMapper.queryById(id);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<TgMidCountry> queryAllByLimit(int offset, int limit) {
        return this.tgMidCountryMapper.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param tgMidCountry 实例对象
     * @return 实例对象
     */
    @Override
    public TgMidCountry insert(TgMidCountry tgMidCountry) {
        this.tgMidCountryMapper.insert(tgMidCountry);
        return tgMidCountry;
    }
    
    /**
     * 新增部分数据
     *
     * @param tgMidCountry 实例对象
     * @return 实例对象
     */
    @Override
    public TgMidCountry insertSelective(TgMidCountry tgMidCountry) {
        this.tgMidCountryMapper.insertSelective(tgMidCountry);
        return tgMidCountry;
    }

    /**
     * 修改数据
     *
     * @param tgMidCountry 实例对象
     * @return 实例对象
     */
    @Override
    public TgMidCountry update(TgMidCountry tgMidCountry) {
        this.tgMidCountryMapper.update(tgMidCountry);
        return this.queryById(tgMidCountry.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(String id) {
        return this.tgMidCountryMapper.deleteById(id) > 0;
    }

    @Override
    public List <TgMidCountry> queryAll(TgMidCountry tgMidCountry) {
        return this.tgMidCountryMapper.queryAll(tgMidCountry);
    }
}